package team3132.commands;

import edu.wpi.first.wpilibj.command.Command;
import team3132.subsystems.DriveSubsystem;
import team3132.utils.Trace;

/**
 * Keep telling the drive subsystem 0 so it doesn't say: "not updated often enough".
 */
public class DriveSubsystemIdleCommand extends Command {

  private final Trace trace;
  private final DriveSubsystem driveSubsystem;

  public DriveSubsystemIdleCommand(DriveSubsystem driveSubsystem) {
    this.trace = new Trace(this);
    this.driveSubsystem = driveSubsystem;
    requires(driveSubsystem);
    setInterruptible(true);
  }

  // Called just before this Command runs the first time
  protected void initialize() {
    trace.trace("Initializing drive subsystem idle command");
  }

  // Called repeatedly when this Command is scheduled to run
  protected void execute() {
    driveSubsystem.set(0);
  }

  // Make this return true when this Command no longer needs to run execute()
  protected boolean isFinished() {
    return false;
  }

  // Called once after isFinished returns true
  protected void end() {
    trace.trace("idle command finishing");
  }

  // Called when another command which requires one or more of the same
  // subsystems is scheduled to run
  protected void interrupted() {
    end();
  }
}
